﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        gridList();
    })
    function gridList() {
        var template1 =
        {
            "groupOp": "AND",
            "rules": [
            { "field": "rolename", "op": "bw", "data": "用户" },
            { "field": "rolecode", "op": "gt", "data": "20" }
            ]
        };

        var template2 =
        {
            "groupOp": "AND",
            "rules": [
              { "field": "rolecode", "op": "eq", "data": "10" },
              { "field": "rolename", "op": "le", "data": "管理员" }
            ]
        };

        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/SystemManage/Role/GetGridJson",
            //postData: { advance_search: "true" },
            height: $(window).height() - 126,
            colModel: [
                { label: "主键", name: "id", hidden: true, key: true },
                { label: '角色名称', name: 'rolename', width: 150, align: 'left' },
                { label: '角色编号', name: 'rolecode', width: 150, align: 'left' },
                { label: '角色有效时间', name: 'roleexpiretime', width: 150, align: 'left' }
            ],
            pager: '#gridPager',
            sortname: 'id asc,roleexpiretime desc',
            viewrecords: true
        });

        jQuery("#gridList").jqGrid('navGrid', '#gridPager',
        { Edit: false, Add: false, del: false },
        {},
        {},
        {},
        {
            multipleSearch: true,
            multipleGroup: true,
            showQuery: true,
            // set the names of the template
            "tmplNames": ["模板一", "模板二"],
            // set the template contents
            "tmplFilters": [template1, template2]
        }
        );

        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                search: false,
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    function btn_Add() {
        $.modalOpen({
            id: "Form",
            title: "新增角色",
            url: "/SystemManage/Role/Form",
            width: "550px",
            height: "570px",
            btn: null
        });
    }
    function btn_Edit() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Form",
            title: "修改角色",
            url: "/SystemManage/Role/Form?keyValue=" + keyValue,
            width: "550px",
            height: "570px",
            btn: null
        });
    }
    function btn_Delete() {
        $.deleteForm({
            url: "/SystemManage/Role/DeleteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
    function btn_Details() {
        var keyValue = $("#gridList").jqGridRowValue().id;
        $.modalOpen({
            id: "Detail",
            title: "查看角色",
            url: "/SystemManage/Role/Details?keyValue=" + keyValue,
            width: "550px",
            height: "620px",
            btn: null,
        });
    }
    function btn_copyandpaste() {
        $.deleteForm({
            url: "/SystemManage/Role/copyAndPasteForm",
            param: { keyValue: $("#gridList").jqGridRowValue().id },
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <a id="NF-Add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_Add()"><i class="fa fa-plus"></i>新建角色</a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">@*authorize="yes"*@
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-Edit" onclick="btn_Edit()"><i class="fa fa-pencil-square-o"></i>修改角色</a></li>
                <li><a id="NF-Delete" onclick="btn_Delete()"><i class="fa fa-trash-o"></i>删除角色</a></li>
                <li><a id="NF-Details" onclick="btn_Details()"><i class="fa fa-search-plus"></i>查看角色</a></li>
               @* <li><a id="NF-copyAndPaste" onclick="btn_copyandpaste()"><i class="fa fa-search-plus"></i>复制粘贴</a></li>*@
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
    </div>
    <div class="search">
        <table>
            <tr>
                <td style="padding-right: 3px;">
                    <div class="btn-group">
                        <a class="btn btn-primary dropdown-text" onclick="advance_search()">高级查询</a>
                    </div>
                </td>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="角色名称" style="width: 200px;">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>

<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>

